package com.airlines.crewassignment.service.crewlocation.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.airlines.common.Page;
import com.airlines.crewassignment.dao.crewlocation.CrewAbsentMapper;
import com.airlines.crewassignment.entity.crewlocation.CrewAbsent;
import com.airlines.crewassignment.service.crewlocation.CrewAbsentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xxxx
 * @date 2018/07/04 16:23:40
 * @company xxxx Airlines
 * @description 不在位信息
 */
@Service
public class CrewAbsentServiceImpl implements CrewAbsentService {

    @Autowired
    private CrewAbsentMapper crewAbsentMapper;

    @Override
    public int insert(CrewAbsent crewAbsent){
        return crewAbsentMapper.insert(crewAbsent);
    }

    @Override
    public int delete(Integer id){
        return crewAbsentMapper.delete(id);
    }


    @Override
    public int update(CrewAbsent crewAbsent){
        return crewAbsentMapper.update(crewAbsent);
    }

    @Override
    public CrewAbsent get(Integer id){
        return crewAbsentMapper.get(id);
    }

    @Override
    public List<CrewAbsent> list(CrewAbsent crewAbsent){
        return crewAbsentMapper.list(crewAbsent);
    }

    @Override
    public Page list(CrewAbsent crewAbsent, Page page){
        PageHelper.startPage(page.getPageNumber(), page.getPageSize());
        List<CrewAbsent> list = crewAbsentMapper.listByFuzzy(crewAbsent);
        PageInfo<CrewAbsent> pageInfo = new PageInfo<CrewAbsent>(list);
        page.setTotal(String.valueOf(pageInfo.getTotal()));
        page.setRows(pageInfo.getList());
        return page;
    }




}
